package com.jinghua.treatment.controller;

import com.jinghua.treatment.common.exception.BizException;
import com.jinghua.treatment.service.ChineseMedicalService;
import io.swagger.annotations.ApiOperation;
import io.swagger.models.auth.In;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.util.StringUtils;
import org.springframework.web.bind.annotation.RequestMapping;

import javax.annotation.Resource;
import java.util.List;

@Controller
@RequestMapping("/chm")
public class ChineseMedicalController {

    @Resource
    ChineseMedicalService chineseMedicalService;

    @ApiOperation(value = "开方搜索药品")
    @RequestMapping(value= "/searchMedical")
    public String searchMedical(String key, Integer doctorId, Model model){
        if(StringUtils.isEmpty(key)||StringUtils.isEmpty(doctorId))
            throw  new BizException("参数缺失");
        List list = chineseMedicalService.searchMedical(key,doctorId);
        model.addAttribute("results",list);
        return  "prescription/medicalSearchResults";
    }
}
